﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Configuration;
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Shapes = Windows.UI.Xaml.Shapes;

namespace BoolanElement
{
    public class BooTwoArrows:BooTextShapesBase
    {
        Shapes.Polygon twoArrows;
        public Shapes.Polygon TwoArrows
        {
            get
            {
                return twoArrows;
            }
            set
            {
                twoArrows = value;
            }
        }

        BooTwoArrowsElement twoArrowsElement;
        public BooTwoArrowsElement TwoArrowsElement 
        {
            get { return twoArrowsElement; }
        }

        public override BooElement Element
        {
            set { twoArrowsElement = (BooTwoArrowsElement)value; }
            get { return twoArrowsElement; }
        }

        public override BooTextShapesBaseElement TextShapesBaseElement
        {
            get { return twoArrowsElement; }
        }

        public override Shapes.Shape Shape
        {
            get { return twoArrows; }
        }

        public BooTwoArrows(BooTwoArrowsElement squareElement, SaveForRedoUndo saveForRedoUndo)
            : base(squareElement)
        {
            this.twoArrowsElement = squareElement;
            InitOriginal();
            base.saveForRedoUndo = saveForRedoUndo;
            Focus.InitFocusEvent(this);
        }

        public BooTwoArrows(BooTwoArrowsElement squareElement)
            : base(squareElement)
        {
            this.twoArrowsElement = squareElement;
            InitOriginalForThumbNails();
        }

        public override void InitShape()
        {
            twoArrows = new Shapes.Polygon();
            twoArrows.Points = BooShapesPoints.CopyPointCollection(this.twoArrowsElement.Points);
            twoArrows.ManipulationMode = ManipulationModes.All;
        }

        public override void ReSizeUI(double x, double y)
        {
            if (twoArrowsElement.ElementTransform.Width + x < 50 || twoArrowsElement.ElementTransform.Height + y < 50)
            {
                return;
            }

            twoArrowsElement.ElementTransform.Width = twoArrowsElement.ElementTransform.Width + x;
            twoArrowsElement.ElementTransform.Height = twoArrowsElement.ElementTransform.Height + y;

            twoArrowsElement.ShapeWidth = twoArrowsElement.ElementTransform.Width;
            twoArrowsElement.ShapeHeight = twoArrowsElement.ElementTransform.Height;

            //this.twoArrows.Width = twoArrowsElement.ElementTransform.Width;
           // this.twoArrows.Height = twoArrowsElement.ElementTransform.Height;

            FullGrid.Width = twoArrowsElement.ElementTransform.Width;
            FullGrid.Height = twoArrowsElement.ElementTransform.Height;

            //BooCanvas.Width = twoArrowsElement.ElementTransform.Width;
            //BooCanvas.Height = twoArrowsElement.ElementTransform.Height;

            CenterStack.Width = twoArrowsElement.ElementTransform.Width;
           // CenterStack.MaxHeight = twoArrowsElement.ElementTransform.Height;


            this.TextBox.Width = twoArrowsElement.ElementTransform.Width;
            twoArrowsElement.TextWidth = twoArrowsElement.ElementTransform.Width;
           // this.TextBox.MaxHeight = twoArrowsElement.ElementTransform.Height;
           // twoArrowsElement.TextMaxHeight = twoArrowsElement.ElementTransform.Height;


            Focus.FocusElls.ScopeRectangle.Width = twoArrowsElement.ElementTransform.Width;
            Focus.FocusElls.ScopeRectangle.Height = twoArrowsElement.ElementTransform.Height;
            Focus.SetFocuseEllipseMargin(twoArrowsElement.ElementTransform.Width, twoArrowsElement.ElementTransform.Height);

            Point[] pt = new Point[twoArrowsElement.Points.Count];
            PointCollection pts = new PointCollection();
            twoArrowsElement.Points.CopyTo(pt, 0);
            pt[0].X = twoArrowsElement.ElementTransform.Width * 0.3333;
            pt[0].Y = 0;
            pt[1].X = twoArrowsElement.ElementTransform.Width*0.3333;
            pt[1].Y = twoArrowsElement.ElementTransform.Height *0.25;
            pt[2].X = twoArrowsElement.ElementTransform.Width * 0.66665;
            pt[2].Y = twoArrowsElement.ElementTransform.Height*0.25;
            pt[3].X = twoArrowsElement.ElementTransform.Width * 0.66665;
            pt[3].Y = 0;
            pt[4].X = twoArrowsElement.ElementTransform.Width;
            pt[4].Y = twoArrowsElement.ElementTransform.Height * 0.5;
            pt[5].X = twoArrowsElement.ElementTransform.Width*0.66665;
            pt[5].Y = twoArrowsElement.ElementTransform.Height;
            pt[6].X = twoArrowsElement.ElementTransform.Width * 0.66665;
            pt[6].Y = twoArrowsElement.ElementTransform.Height * 0.75;
            pt[7].X = twoArrowsElement.ElementTransform.Width * 0.3333;
            pt[7].Y = twoArrowsElement.ElementTransform.Height * 0.75;
            pt[8].X = twoArrowsElement.ElementTransform.Width * 0.3333;
            pt[8].Y = twoArrowsElement.ElementTransform.Height;
            pt[9].X = 0;
            pt[9].Y = twoArrowsElement.ElementTransform.Height * 0.5;
            pts.Add(pt[0]);
            pts.Add(pt[1]);
            pts.Add(pt[2]);
            pts.Add(pt[3]);
            pts.Add(pt[4]);
            pts.Add(pt[5]);
            pts.Add(pt[6]);
            pts.Add(pt[7]);
            pts.Add(pt[8]);
            pts.Add(pt[9]);
            twoArrows.Points = pts;
            twoArrowsElement.Points = pts;
        }

        public override void ReMargin(double x, double y)
        {
            this.Element.ElementTransform.Translate.X += x;
            this.Element.ElementTransform.Translate.Y += y;
        }
    }
}
